<?
//inculde即可以使用data数据。本页所有的data数据，倾在controller都处理好
include_once("../../../../../config.php");
include_once("/../../../../common/module/checkA.php");
include_once("../../controller/detail-statistic.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link href="../../asset/css/style.css?version=2024" rel="stylesheet" type="text/css"/>

    <?php include ROOT_PATH_.'/controller/common/module/head.php'; ?>
    <!--kindeditor编辑器-->
    <?php include_once(TASK_PATH_.'/mod-nkeditor.php'); ?>
</head>
<style>
    html{
        background: #fff;
    }
    #content{
        margin: 0;
    }
    .detail-box{
        margin: 0px 0 70px 0!important;
    }
    .detail-box .function{
        margin-left: 0;
    }
    .ke-edit{height:150px!important;}

    #content{box-shadow: none}

    .voucher {background-color: #ececec;padding: 15px;cursor: pointer}
    .voucher img{max-width: 100%;max-height:100px}

</style>
<body>
<div id="content" style="overflow: hidden">
    <?php $page_title='任务信息';?>
    <?php include ROOT_PATH_.'/controller/common/module/mod-page-title.php'; ?>

    <form id="edit-member-form" method="post"
        action="../detail-edit-function.php?sys_part=task&nowpageid=<?echo $nowpageid?>" 
        enctype="multipart/form-data" class="layui-form detail-box form-container">

            <div class="col-6">
                <div class="layui-form-item">
                    <label class="layui-form-label">任务标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="ai_title" id="title" required  lay-verify="required" placeholder="请输入任务标题" autocomplete="off" class="layui-input" value="<? echo $task['title']?>">
                    </div>
                </div>

                <?

                $principal_list=select_lines_all_items($table_Prefix."employee","nid desc","status = '在职'","0");
                $member_name_list=transform_2darray_in_1darray_with_new_key($principal_list,"nid",'name');
                $principal=select_one_line_all_items($table_Prefix."employee","nid = '".$detail['principal']."'");
                ?>

                <div class="layui-form-item">
                    <label class="layui-form-label">执行人</label>
                    <div class="layui-input-block">
                        <select name="ai_principal" lay-search="">
                            <option  value="无" > 无</option>
                            <? for($i=0;$i<count($principal_list);$i++){ ?>
                                <option value="<? echo $principal_list[$i]['nid'] ?>" <?php if($task['principal'] == $principal_list[$i]['nid']){echo "selected";} ?> ><? echo $principal_list[$i]['nid'] ?> : <? echo $principal_list[$i]['name'] ?></option>
                            <? } ?>
                        </select>
                    </div>
                </div>


                <?
                    $case_list=select_lines_all_items($table_Prefix."case","FIELD(status, '询价中', '进行中', '完成','客户终止') ,startdate desc,nid desc","","0");
                    //获取要用到的单位名字
                    $unit_nid_list=transform_2darray_in_1darray_with_new_key($case_list,"nid","unit");
                    $unit_nid_list_str=implode("','",$unit_nid_list);
                    $unit_list=select_lines_all_items($table_Prefix."unit","","nid in ('".$unit_nid_list_str."')","");
                    $unit_name_list=transform_2darray_in_1darray_with_new_key($unit_list,"nid","sname");
                ?>

                <div class="layui-form-item">
                    <label class="layui-form-label">项目</label>
                    <div class="layui-input-block">
                        <select name="ai_case_id" lay-search="" >
                            <option value="">无</option>
                            <? for($i=0;$i<count($case_list);$i++){ ?>
                                <option value="<? echo $case_list[$i]['nid'] ?>" <?php if($task['case_id'] == $case_list[$i]['nid']){echo "selected";} ?> ><? echo $case_list[$i]['nid'] ?> :【<?echo $unit_name_list[$case_list[$i]['unit']]?>】<? echo $case_list[$i]['name']?>-<?echo $case_list[$i]['status']?></option>
                            <? } ?>
                        </select>
                    </div>
                </div>
            </div>

            <div class="col-6">
                <div class="layui-form-item">
                    <label class="layui-form-label">开始时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="ai_startdate" id="start_date" autocomplete="off" class="layui-input"  value="<? echo $task['startdate']?>" class="laydate-icon" placeholder="请选择开始时间">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">截止时间</label>
                    <div class="layui-input-block end_date_container">
                        <input type="text" name="ai_enddate" id="end_date"
                               autocomplete="off" class="layui-input"
                               value="<? echo $task['enddate']?>"
                               <?php if (!$auth)
                               {
                                  echo "disabled";
                               }
                               ?>
                               class="laydate-icon" placeholder="请选择截止时间">
                    </div>
                </div>

                <?php if ($auth): ?>
                    <div class="layui-form-item">
                        <label class="layui-form-label">完成时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="ai_completedate" id="complete_date" autocomplete="off" class="layui-input"
                                   value="<?php
                                   if(($task['status']=='待审核') or ($task['status']=='已完成'))
                                   {
                                       if($task['completedate']){echo $task['completedate'];}else{echo $task['enddate'];}
                                   }
                                   ?>"
                                   class="laydate-icon" placeholder="请选择完成时间">
                        </div>
                    </div>
                <?php endif; ?>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea id="ai_note" name="ai_note" cols="77"><?php echo $task['note'] ?></textarea>
                </div>
            </div>
            
            <div class="layui-form-item" style="margin-bottom: 0px;">
                <label class="layui-form-label">优先级</label>
                <div class="layui-input-block">
                    <input type="radio" name="ai_priority" value="无" title="无"
                        <? if($task['priority']=="无"){echo "checked";} ?>
                    >

                    <input type="radio" name="ai_priority" value="普通" title="普通"
                        <? if($task['priority']=="普通"){echo "checked";} ?>
                    >

                    <input type="radio" name="ai_priority" value="紧急" title="紧急"
                        <? if($task['priority']=="紧急"){echo "checked";} ?>
                    >
                </div>
            </div>

            <div class="layui-form-item" style="margin-bottom: 0px;">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
        
                    <input type="radio" name="ai_status" value="未开始" title="未开始"
                        <? if($task['status']=="未开始"){echo "checked";} ?>
                    >

                    <input type="radio" name="ai_status" value="进行中" title="进行中"
                        <? if($task['status']=="进行中"){echo "checked";} ?>
                    >
                    
                    <input type="radio" name="ai_status" value="待审核" title="待审核"
                        <? if($task['status']=='待审核'){echo "checked";} ?>
                    >
                        
                    <?php if ($auth): ?>
                        <input type="radio" name="ai_status" value="已完成" title="已完成"
                        <? if($task['status']=="已完成"){echo "checked";} ?>
                    >
                    <?php endif; ?>
                </div>
            </div>

            <div class="layui-form-item" style="margin-bottom:5px;">
                <label class="layui-form-label">任务重复</label>
                <div class="layui-input-block">
                    <input type="radio" name="ai_circulate" value="不重复" title="不重复"
                        <? if(($task['circulate']=="不重复")or($task['circulate']=="")){echo "checked";} ?>
                    >
                    <input type="radio" name="ai_circulate" value="每天重复" title="每天"
                        <? if($task['circulate']=="每天重复"){echo "checked";} ?>
                    >
                    <input type="radio" name="ai_circulate" value="每周重复" title="每周"
                        <? if($task['circulate']=="每周重复"){echo "checked";} ?>
                    >
                    <input type="radio" name="ai_circulate" value="每月重复" title="每月"
                        <? if($task['circulate']=="每月重复"){echo "checked";} ?>
                    >
                    <input type="radio" name="ai_circulate" value="季度重复" title="季度"
                        <? if($task['circulate']=="季度重复"){echo "checked";} ?>
                    >
                    <input type="radio" name="ai_circulate" value="每年重复" title="每年"
                        <? if($task['circulate']=="每年重复"){echo "checked";} ?>
                    >
                    <div class="layui-col-md12">
                        <div class="notice">当任务状态被更改为已完成时，按任务的重复周期自动创建新任务，默认为不重复</div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item" id="voucher-item">
                <label class="layui-form-label">凭证</label>
                <div class="layui-input-block" >
                    <textarea id="ai_voucher" name="ai_voucher" cols="77"><?php echo $task['voucher'] ?></textarea>
                </div>
            </div>

            <input type="hidden" name="nid"        value="<? echo $_REQUEST['nid'] ?>">
            <input type="hidden" name="sys_part"   value="<? echo $_REQUEST['sys_part'] ?>">
            <input type="hidden" name="nowpageid"  value="<? echo $_REQUEST['nowpageid'] ?>"/>
            <input type="hidden" name="sortby"     value="<? echo $_REQUEST['sortby'] ?>"/>

            <div class="function">
                <button class="layui-btn" lay-submit lay-filter="formTaskBtn" type="submit" id="taskBtn">立即提交</button>
                <?php if ($auth): ?>
                    <button class="layui-btn layui-bg-red" onclick="realDel(<?php echo $task['nid'] ?>)">删除</button>
                <?php endif; ?>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
    </form>







    <div class="detail-box comment-container">
        <div class="comment-list" id="log-list">

            <?if($task['voucher']){?>
            <span id='no-data'>任务凭证(点击放大)</span>
                <div class="voucher" onclick="windowEject_voucher('mod-detail-voucher.php?nid=<? echo $task['nid']?>')">
                        <?php echo $task['voucher'] ?>
                </div>
            <?}?>


            <?php if(!count($task_comment)){echo "<span id='no-data'>暂无消息</span>";}?>
            <?php for($i=0;$i<count($task_comment);$i++){ ?>
                <?php $employee=select_one_line_all_items($table_Prefix."employee","nid = '".$task_comment[$i]['user_id']."'");?>
                    <div class="item">
                        <div class="left">
                            <div class="img-box">
                                <?php if($employee['photo']){?>
                                    <img src="../../../../../uploadfiles/<?php echo $employee['photo']; ?>">
                                <?php }else{ ?>
                                    <img src="../../../../../uploadfiles/default.png">
                                <?php } ?>
                            </div>
                        </div>
                        <div class="right">
                            <div class="layui-col-md12 head">
                                <p class="name"><span class="layui-badge layui-bg-green"><?php echo $employee['name'] ?></span></p>
                                <p class="date"><?php echo $task_comment[$i]['date']?></p>
                            </div>



                            <?if($task_comment[$i]['notice_member']){?>
                            <p class="notice_list">
                                <span class="layui-badge layui-bg-green">通知</span>
                                <?
                                $_notice_member=explode(",",$task_comment[$i]['notice_member']);
                                $_notice_member_read=explode(",",$task_comment[$i]['notice_member_read']);

                                foreach ($_notice_member as $k=>$v){?>
                                <span class="layui-badge  <?if(in_array($v,$_notice_member_read)){echo "layui-bg-green";}?> "><?echo $member_name_list[$v]?></span>
                                <?;}?>
                            </p>
                            <?;}?>


                            <div class="layui-col-md12 content">
                                <!-- 移除图片换行产生的换行符 -->
                                <?php $content = preg_replace('/<br>|<br \/>/i', '', $task_comment[$i]['content']); ?>
                                <?php echo $content ?>
                                <div class="img-group"></div>
                            </div>
                        </div>
                    </div>
            <?php } ?>
        </div>


        <div class="reply layui-form">
            <h6>通知他们</h6>
            <div class="notice_member">
                <?
                foreach ($principal_list as $k => $v) {
                    if (($v['status'] == "在职") and ($v['nid'] != $_SESSION['nidx'])) {
                        ?>
                        <span><input type="checkbox" name="ai_notice_member"
                                     value="<? echo $v['nid'] ?>"
                                     title="<? echo $v['name'] ?>"
                                     lay-skin="primary" <? if ($task['principal'] == $v['nid']) {
                                echo "checked";
                            } ?>>
                    </span>
                    <? };
                } ?>
            </div>


            <textarea id="ai_content" name="ai_content" cols="60"></textarea>
            <input type="hidden" name="user_id" value="<? echo $_SESSION['nid'] ?>">
            <button type="button" class="layui-btn layui-btn-sm" id="reply" onclick="reply()">回复</button>
        </div>
    </div>
</div>
</body>

<script src="../../asset/js/create_task_log.js?version=2024"></script>
<script src="../../asset/js/date.js?version=2023"></script>
<script src="../../asset/js/windowEject_voucher.js?version=2023"></script>
</html>